#pragma once
#include <omp.h>
#include <vector>
#include "SubSystem.h"

class SubSystemManager {

public: 
	std::vector<SubSystem*> subsystemsVector;

	SubSystemManager() { subsystemsVector.clear(); }
	void onInit() { 
		#pragma omp parallel for schedule (dynamic)
		for(int i = 0; i < static_cast<int>(subsystemsVector.size()); i++)
		{
			subsystemsVector[i]->onInit();
		}
	}
	void onUpdate() {
		#pragma omp parallel for schedule (dynamic)
		for(int i = 0; i < static_cast<int>(subsystemsVector.size()); i++)
		{
			if(subsystemsVector[i]->isUpdatable())
			{
				subsystemsVector[i]->onUpdate();
			}
		}
	}
	void onDraw() {
		#pragma omp parallel for schedule (dynamic)
		for(int i = 0; i < static_cast<int>(subsystemsVector.size()); i++)
		{
			if(subsystemsVector[i]->isRenderable())
			{
				subsystemsVector[i]->onDraw();
			}
		}
	
	}

	void addSubsystem(SubSystem* sys) {
		subsystemsVector.push_back(sys);
	}

};